import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex);
const state = {
    username: null,		//用户名
    permission: [],		//菜单权限
    systemId: null,		//系统id
    companyName: null,	//公司名称
	systemInfo: [],		//存储系统信息
    options: {          //滚动条样式设置
        vuescroll: {
            mode: 'native'
        },
        bar: {
            background: '#1874CD',
            keepShow: false,            //是否保持显示
            opacity: .7,
            size: '6px'
        }
    },
    initializeVal: [],      //初始化页面的表格数据
    initailizeId:[],        //初始化表格数据id
}

const mutations = {
	updateUsername(state, uname) {
		state.username = uname;
	},
	updatePermission(state, arr) {		//更新权限
		let permission = state.permission;
		permission.length = 0;
		arr.forEach(item => permission.push(item));
	},
	updateSystemId(state, id) {			//系统id
		state.systemId = id;
	},
	updateCompanyNames(state, name) {       //更新公司名称
        state.companyName = name;
    },
    updateSystemInfo(state, obj) {
        state.systemInfo.splice(0, 1, obj);
    },
    setInitializeVal(state, data){                     //初始化页面的表格字段
        let initializeVal = state.initializeVal;
        initializeVal.length = 0;          //清空数组
        data.forEach(item => initializeVal.push(item));
    },
    setInitializeValId(state,id){
        state.initailizeId = id;
    },
    clearInitializeVal(state){              //清空初始化页面的表格字段
        state.initializeVal.length = 0;
    }
}

import loginStore from '@/components/login/store'
import accountStore from '@/components/basicData/account/store'         //账套管理
import currencyTypeStore from '@/components/basicData/currencyType/store'       //币别
import meterUnitStore from '@/components/basicData/meterUnit/store'         //计量单位
import settlementWayStore from '@/components/basicData/settlementWay/store'         //结算方式
import accountSubjectStore from '@/components/basicData/accountSubject/store'       //会计科目
import checkItemsStore from '@/components/basicData/checkItems/store'               //核算项目
import verifyProcessStore from '@/components/basicData/verifyProcess/store'         //审批流程
import auxiliaryStore from '@/components/basicData/auxiliary/store'             //辅助资料
import departmentStore from '@/components/basicData/department/store'           //部门
import customerStore from '@/components/basicData/customer/store'           //客户资料
import supplierStore from '@/components/basicData/supplier/store'           //供应商
import userGroupStore from '@/components/basicData/userGroup/store'         //用户组
import userManagementStore from '@/components/basicData/userManagement/store'           //用户管理
import initializeStore from '@/components/basicData/initialize/store'          //初始化
import empStore from '@/components/basicData/employee/store'                //职员
import netLogStore from '@/components/basicData/netLog/store'               //上机日志
import cityDictionaryStore from '@/components/basicData/cityDictionary/store'           //城市字典
import borrowCategoryStore from '@/components/basicData/borrowCategory/store'           //借款类别模板
import borrowOrderStore from '@/components/financial/borrowOrder/store'             //借款单
import borrowApproveOrderStore from '@/components/financial/borrowApproveOrder/store'             //借款审批单

const store = new Vuex.Store({
    state,
    mutations,
    modules: {
        loginStore,
        accountStore,
        currencyTypeStore,
        meterUnitStore,
        settlementWayStore,
        accountSubjectStore,
        checkItemsStore,
        verifyProcessStore,
        auxiliaryStore,
        departmentStore,
        customerStore,
        supplierStore,
        userGroupStore,
        userManagementStore,
        initializeStore,
        empStore,
        netLogStore,
        cityDictionaryStore,
        borrowCategoryStore,
        borrowOrderStore,
        borrowApproveOrderStore
    }
});

export default store;